package com.xbongbong.pro.enums;

import com.xbongbong.i18n.util.I18nMessageUtil;
import java.util.ArrayList;
import java.util.List;
import lombok.Getter;

/**
 * @description: 自定义执行策略类型枚举
 * @Author: hongxiao
 * @date: 2019-04-24 14:24
 * @since v1.0
 */
@Getter
public enum CustomStrategyTypeEnum {
    /**
     * 自定义执行策略类型枚举
     */
    WEEKLY(1, "enum.customStrategyType.memo.weekly"),
    MONTHLY(2, "enum.customStrategyType.memo.monthly"),
    ;

    /**
     * 执行策略类型标识值
     */
    private Integer code;
    /**
     * 执行策略类型描述
     */
    private String memo;

    CustomStrategyTypeEnum(Integer code, String memo) {
        this.code = code;
        this.memo = memo;
    }

    public static CustomStrategyTypeEnum getByCode(Integer code){
        for(CustomStrategyTypeEnum strategyTypeEnum: values()){
            if(strategyTypeEnum.getCode().equals(code)){
                return strategyTypeEnum;
            }
        }
        return null;
    }

    /**
     * 获取全部枚举
     *
     * @return List<CustomStrategyTypeEnum>
     */
    public static List<CustomStrategyTypeEnum> getAllEnum() {
        List<CustomStrategyTypeEnum> list = new ArrayList<>();
        for (CustomStrategyTypeEnum cache : values()) {
            list.add(cache);
        }
        return list;
    }

    public String getMemo() {
        return I18nMessageUtil.getMessage(memo);
    }
}
